>> >> >> x = [4,1,6,8,2,7,9]; >> x(3) ans = 6 >> >> >> x(1:5) ans = 4 1 6 8 2 >> >> >> x(4:end) ans = 8 2 7 9 >> x(end:-2:1) ans = 9 2 6 4 >> >> >> x([1,5,3,2,2]) ans = 4 2 6 1 1 >> >> >> sum(x) ans = 37 >> >> >> x = (16:2:49); >> x x = 16 18 20 22 24 26 28 30 32 34 36 38 40 42 44 46 48 >> x = (16:2:49); >> x = (16:2:49) x = 16 18 20 22 24 26 28 30 32 34 36 38 40 42 44 46 48 >> >> >> >> x = [2,9,7,5,3] x = 2 9 7 5 3 >> >> x-11 ans = -9 -2 -4 -6 -8 >> x*2 ans = 4 18 14 10 6 >> x.*2 ans = 4 18 14 10 6 >> x.^2 ans = 4 81 49 25 9 >> x' ans = 2 9 7 5 3 >> x = [3,2,6,8]' x = 3 2 6 8 >> y = [4,1,3,5]' y = 4 1 3 5 >> y+sum(x) ans = 23 20 22 24 >> x.^y ans = 81 2 216 32768 >> x./y ans = 0.7500 2.0000 2.0000 1.6000 >> >> >> z = zeros(1,50) z = Columns 1 through 21 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 22 through 42 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 43 through 50 0 0 0 0 0 0 0 0 >> o = ones(1,50) o = Columns 1 through 21 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Columns 22 through 42 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Columns 43 through 50 1 1 1 1 1 1 1 1 >> r = round(rand(1,50)*10) r = Columns 1 through 21 8 9 1 9 6 1 3 5 10 10 2 10 10 5 8 1 4 9 8 10 7 Columns 22 through 42 0 8 9 7 8 7 4 7 2 7 0 3 0 1 8 7 3 10 0 4 4 Columns 43 through 50 8 8 2 5 4 6 7 8 >> >> figure >> hold on >> plot(z,'b'); plot(o,'k'); plot(r, 'm') >> hold off >> >> >> figure >> hold on >> stem(z,'r');stem(o,'g'); stem(r,'y') >> hold off >> subplot(2,1,1) hold on plot(z,'r');plot(o,'k'); plot(r,'b') hold off subplot(2,1,2) hold on stem(z,'m'); stem(o,'g'); stem(r,'k') hold off >> M = [2,4,1;6,7,2;3,5,9] M = 2 4 1 6 7 2 3 5 9 >> Msub = M(1:2,:) Msub = 2 4 1 6 7 2 >> sum(M(1,:)) ans = 7 >> sum(M(2,:)) ans = 15 >> sum(M(3,:)) ans = 17 >> sum(M(:,1)) ans = 11 >> >> sum(M(:,2)) ans = 16 >> sum(M(:,3)) ans = 12 >> load gong.mat >> soundsc(y) >> audiowrite('gong.wav',y,Fs) >> load handel.mat >> soundsc(y) >> audiowrite('handel.wav',y,Fs) >>